/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package lt.ntec.danblog.server.login;

import java.util.Random;
import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;
import lt.ntec.danblog.server.core.UserManager;
import lt.ntec.danblog.server.core.http.Flow;
import lt.ntec.danblog.server.core.view.View;

/**
 *
 * @author Tadas
 */
public class Controller {
    
    @Inject
    private Flow flow;
    
    @Inject
    private UserManager userManager;
    
    @Inject
    private HttpServletRequest request;

    public void loginAction() {
        String referer = request.getHeader("referer");
        String loginUrl = userManager.getLoginUrl(referer);
        flow.redirect(loginUrl);
    }
    
    public void logoutAction() {
        String referer = request.getHeader("referer");
        String logoutUrl = userManager.getLogoutUrl(referer);
        flow.redirect(logoutUrl);
    }
}
